package com.deke.course.service.Impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.deke.course.dao.CoreShoucangTeacherDao;
import com.deke.course.dao.TbShoucangTeacherDao;
import com.deke.course.service.CoreShoucangTeacherService;
import com.deke.course.vo.TbShoucangTeacherVo;
import com.deke.entity.EduTeacher;
import com.deke.entity.TbShoucangTeacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：陈昂（731712841@qq.com）
 * @date ：Created in 2023/1/5 15:53
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class CoreShoucangTeacherServiceImpl implements CoreShoucangTeacherService {
    @Autowired
    private CoreShoucangTeacherDao coreShoucangTeacherDao;
    @Autowired
    private TbShoucangTeacherDao tbShoucangTeacherDao;

    /**
     * 根据用户i调查询关注得讲师
     * @param HuiYuanId 用户id
     * @return
     */
    @Override
    public List<EduTeacher> findAttentionTeacherById(String HuiYuanId) {
        List<EduTeacher>teacherById = coreShoucangTeacherDao.findAttentionTeacherById(HuiYuanId);
        return teacherById;
    }
    /**
     * 取消关注
     * @param tbShoucangTeacherVo 取消条件
     * @return
     */
    @Override
    public int deleteAttentionTeacher(TbShoucangTeacherVo tbShoucangTeacherVo) {
        // 根据用户id和教师id删除
        UpdateWrapper<TbShoucangTeacher> wrapper = new UpdateWrapper<>();
        wrapper.eq("member_id", tbShoucangTeacherVo.getMemberid());
        wrapper.eq("teacher_id", tbShoucangTeacherVo.getTeacherid());
        return tbShoucangTeacherDao.delete(wrapper);
    }
}
